﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;

namespace MvcControlsToolkit
{
    public class BarRendererOptions: RendererOptions
    {
        /// <summary>
        /// ‘vertical’ = up and down bars, ‘horizontal’ = side to side bars
        /// </summary>
        public string BarDirection
        {
            get
            {
                return GetString("barDirection");
            }
            set { SetString("barDirection", value); }
        }

        /// <summary>
        /// Number of pixels between adjacent bars at the same axis value
        /// </summary>
        public int BarPadding
        {
            get
            {
                if (Attributes.ContainsKey("barPadding"))
                    return int.Parse(Attributes["barPadding"]);
                else return 8;
            }
            set { Attributes["barPadding"] = value.ToString().ToLower(); }
        }

        /// <summary>
        /// Number of pixels between groups of bars at adjacent axis values
        /// </summary>
        public int BarMargin
        {
            get
            {
                if (Attributes.ContainsKey("barMargin"))
                    return int.Parse(Attributes["barMargin"]);
                else return 10;
            }
            set { Attributes["barMargin"] = value.ToString().ToLower(); }
        }

        /// <summary>
        /// Width of the bar in pixels (auto by devaul)
        /// </summary>
        public int BarWidth
        {
            get
            {
                if (Attributes.ContainsKey("barWidth"))
                    return int.Parse(Attributes["barWidth"]);
                else return 0;
            }
            set { Attributes["barWidth"] = value.ToString().ToLower(); }
        }

        

        /// <summary>
        /// True to enable waterfall plot
        /// </summary>
        public bool Waterfall
        {
            get
            {
                if (Attributes.ContainsKey("waterfall"))
                    return Boolean.Parse(GetString("waterfall"));
                else
                    return false;
            }

            set
            {
                Attributes["waterfall"] = value.ToString().ToLower();
            }
        }

        /// <summary>
        /// Group bars into this many groups
        /// </summary>
        public int Groups
        {
            get
            {
                if (Attributes.ContainsKey("groups"))
                    return int.Parse(Attributes["groups"]);
                else return 1;
            }
            set { Attributes["groups"] = value.ToString().ToLower(); }
        }

        /// <summary>
        /// True to color each bar of a series separately rather than have every bar of a given series the same color
        /// </summary>
        public bool VaryBarColor
        {
            get
            {
                if (Attributes.ContainsKey("varyBarColor"))
                    return Boolean.Parse(GetString("varyBarColor"));
                else
                    return false;
            }

            set
            {
                Attributes["varyBarColor"] = value.ToString().ToLower();
            }
        }        
    }
}
